package qiyu;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * stream 传参
 */
public class StreamMethod {

    public List  add(List list, Function function){
      return (List)  list.stream().map(function).collect(Collectors.toList());
    }
    public void foreach(List list){
        list.stream().forEach(System.out::println);
    }

    public static void main(String[] args) {
        List nameList = new ArrayList(Arrays.asList(new String[]{"王飞","天多","白菜多","王多针"}));
        StreamMethod stream = new StreamMethod();
        List list =  stream.add(nameList,(item)->{
            return (String)item+"天天日";
        });
        stream.foreach(list);
    }
}
